package zeebe.param;

import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.zeebe.client.ZeebeClient;

public class ParamStart {
    public static void main(String[] args) {
        ZeebeClient client = ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("启动工作流");
        String processId = "param";

        User user = new User();
        user.setAge(16);
        user.setDescripe(new JsonObject().put("sad", "bad"));

        Person person = new Person();
        person.setName("xiongjie");
        person.setData(new JsonObject().put("happy", "good"));
        person.setUser(user);

        JsonObject data = new JsonObject().put("hello", Json.encode(person));
        String param = data.encode();

        client.newCreateInstanceCommand()
                .bpmnProcessId(processId)
                .latestVersion()
                .variables(param)
                .send()
                .join();
    }
}
